package com.qinggeng.common.enums;

import com.qinggeng.common.exception.CustomException;

/**
 * 用户状态
 *
 * @author qinggeng
 */
public enum ChannelTypeEnum
{
    IOS("ios", "苹果用户端"), ANDROID("android", "安卓用户端"),IOS_GGZY("ios_ggzy","苹果骑手端"), ANDROID_GGZY("android_ggzy", "安卓骑手端"),WEIXIN("weixin","微信小程序");

    private final String code;
    private final String info;

    ChannelTypeEnum(String code, String info)
    {
        this.code = code;
        this.info = info;
    }

    public static void check(String channelType) {
        if (valuesOf(channelType) == null){
            throw new CustomException("通道不存在");
        }
    }

    public String getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }

    public static ChannelTypeEnum valuesOf(String code){
        for (ChannelTypeEnum enums: ChannelTypeEnum.values()){
            if (enums.getCode().equals(code)){
                return enums;
            }
        }
        return null;
    }
}
